#include <iostream>
#include <vector>
#include <algorithm>

struct TreeNode {
    int val;
    TreeNode* left;
    TreeNode* right;
    TreeNode() : val(0), left(nullptr), right(nullptr) {}
    TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}
    TreeNode(int x, TreeNode* left, TreeNode* right) : val(x), left(left), right(right) {}
};

using namespace std;

vector<int> arr;

void dfs(TreeNode* root)
{
    if (root == nullptr)
        return;

    dfs(root->left);
    arr.push_back(root->val);
    dfs(root->right);
}

int kthSmallest(TreeNode* root, int k) {
    dfs(root);

    sort(arr.begin(), arr.end());


    return arr[k - 1];
}


int main()
{

	return 0;
}